﻿Imports System.Data
Imports System.Data.Odbc
Imports WSEntidades
Imports Utilerias
Imports Npgsql
Imports MySql.Data.MySqlClient
Public Class SucursalesFact
    Public Shared Function Build(ByVal dr As MySqlDataReader) As SucursalesBE
        Dim tmpSucursales As SucursalesBE = New SucursalesBE()
        Try
            With tmpSucursales
                '.IdEmpresa = convertDTFromDb.convertInt32(dr.Item("IdEmpresa"))
                '.IdSucursal = convertDTFromDb.convertInt32(dr.Item("IdSuc"))
                .ClaveSucursal = convertDTFromDb.ConvertString(dr.Item("CveSuc"))
                .NombreSucursal = convertDTFromDb.ConvertString(dr.Item("NombreSuc"))
                .Calle = convertDTFromDb.ConvertString(dr.Item("Calle"))
                .NumExterior = convertDTFromDb.ConvertString(dr.Item("NumExt"))
                .NumInterior = convertDTFromDb.ConvertString(dr.Item("NumInt"))
                .Colonia = convertDTFromDb.ConvertString(dr.Item("Colonia"))
                .Localidad = convertDTFromDb.ConvertString(dr.Item("Localidad"))
                .Referencia = convertDTFromDb.ConvertString(dr.Item("Referencia"))
                .Municipio = convertDTFromDb.ConvertString(dr.Item("Municipio"))
                .Estado = convertDTFromDb.ConvertString(dr.Item("Estado"))
                .Pais = convertDTFromDb.ConvertString(dr.Item("Pais"))
                .CP = convertDTFromDb.ConvertString(dr.Item("CP"))
                Select Case convertDTFromDb.ConvertString(dr.Item("Status"))
                    Case "A"
                        .Status = SucursalesBE.EstatusSucursal.Activa
                    Case "I"
                        .Status = SucursalesBE.EstatusSucursal.Inactiva
                    Case Else
                        .Status = SucursalesBE.EstatusSucursal.Inactiva
                End Select
                .Telefono = convertDTFromDb.ConvertString(dr.Item("Telefono"))
                .Correo = convertDTFromDb.ConvertString(dr.Item("Correo"))
                .ClavePemex = convertDTFromDb.ConvertString(dr.Item("CvePemex"))
            End With
            Return tmpSucursales
        Catch ex As Exception
            Throw
        Finally
            tmpSucursales = Nothing
        End Try
    End Function
End Class
